<!DOCTYPE html>
<html>
<head>
    <title>财务缴款单据打印</title>
<#include "../common/common.ftl"/>
</head>
<body style="overflow-y: hidden;">
<div class="layui-fluid">
    <blockquote class="layui-elem-quote layui-bg-white">
        单据打印【姓名：<span class="jmdf-color-red">${(contract.name)!}</span>】【协议编号：<span
            class="jmdf-color-red">${(contract.contractCode)!}</span>】
    </blockquote>
    <div class="layui-col-xs12">
        <div class="layui-card">
            <div class="layui-card-body">
                <table class="layui-table">
                    <tr class="layui-bg-gray">
                        <th style="text-align: center;width: 4%;">序号</th>
                        <th style="text-align: center;">安置项目</th>
                        <th style="text-align: center;">安置房源（车位）信息</th>
                        <th style="text-align: center;">建筑面积（㎡）</th>
                        <th style="text-align: center;">户型（车位类型）</th>
                        <th style="text-align: center;">缴款状态</th>
                        <th style="text-align: center;">缴款时间</th>
                        <th style="text-align: center;width: 16%;">操作</th>
                    </tr>
                <#assign index=0>
                <#list houseList as house>
                    <#assign index=house_index+1>
                    <tr>
                        <td style="text-align: center;">${index}</td>
                        <td style="text-align: center;">${(house.azProject.projectName)!}</td>
                        <td style="text-align: center;">${(house.buildNum)!}
                            栋${(house.floor)!}层${(house.buildNumStr)!}</td>
                        <td style="text-align: center;">${(house.buildArea)!}<span
                                class="jmdf-color-red">【${(house.poolArea)!}</span>】
                        </td>
                        <td style="text-align: center;">${(houseHoldMap[house.houseHold].name)!}</td>
                        <td style="text-align: center;">${(financeMap[house.financeSettleStatus?c].name)!}</td>

                        <td style="text-align: center;">${(house.financeSettleDate?string('yyyy-MM-dd'))!}</td>
                        <td style="text-align: center;">
                            <button type="button"
                                    class="layui-btn layui-btn-xs setHouseFinanceSettleStatus  <#if house.financeSettleStatus == 2>layui-btn-danger</#if>"
                                    houseId=${(house.id)!} financeSettleStatus=${house.financeSettleStatus}>
                                <i class="layui-icon layui-icon-edit"></i>
                                <#if house.financeSettleStatus == 1>设置为已结清<#else>设置为未结清</#if>
                            </button>
                        </td>
                    </tr>
                </#list>
                <#list carLotList as carLot>
                    <#assign index=index+1>
                    <tr>
                        <td style="text-align: center;">${index}</td>
                        <td style="text-align: center;">${(carLot.azProject.projectName)!}</td>
                        <td style="text-align: center;">${(carLot.buildNum)!}${(carLot.houseNumStr)!}</td>
                        <td style="text-align: center;">${(carLot.buildArea)!}</td>
                        <td style="text-align: center;">${(carLotTypeMap[carLot.carLotType?c].name)}</td>
                        <td style="text-align: center;">${(financeMap[carLot.financeSettleStatus?c].name)!}</td>
                        <td style="text-align: center;">${(carLot.financeSettleDate?string('yyyy-MM-dd'))!}</td>
                        <td style="text-align: center;">
                            <button type="button"
                                    class="layui-btn layui-btn-xs setCarLotFinanceSettleStatus  <#if carLot.financeSettleStatus == 2>layui-btn-danger</#if>"
                                    carLotId=${(carLot.id)!} financeSettleStatus=${carLot.financeSettleStatus}>
                                <i class="layui-icon layui-icon-edit"></i>
                                <#if carLot.financeSettleStatus == 1>设置为已结清<#else>设置为未结清</#if>
                            </button>
                        </td>
                    </tr>
                </#list>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['jquery', 'form', 'layer', 'element', 'jmdf'], function () {
        var $ = layui.jquery, jmdf = layui.jmdf, form = layui.form, layer = layui.layer, element = layui.element;

        $(".setHouseFinanceSettleStatus").click(function () {
            var obj = $(this);
            var houseId = obj.attr("houseId");
            var financeSettleStatus = obj.attr("financeSettleStatus");
            var msg = financeSettleStatus == 1 ? "已结清" : "未结清";
            layer.open({
                title: false, shade: 0.5, content: "确认设置为" + msg + "吗？", btn: ['确定', '取消'], closeBtn: 0, btnAlign: 'c'
                , yes: function (index) {
                    $.get("setHouseFinanceSettleStatus", {
                        houseId: houseId,
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            parent.parent.loadData();
                            layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        });

        $(".setCarLotFinanceSettleStatus").click(function () {
            var obj = $(this);
            var carLotId = obj.attr("carLotId");
            var financeSettleStatus = obj.attr("financeSettleStatus");
            var msg = financeSettleStatus == 1 ? "已结清" : "未结清";

            layer.open({
                title: false, shade: 0.5, content: "确认设置为" + msg + "吗？", btn: ['确定', '取消'], closeBtn: 0, btnAlign: 'c'
                , yes: function (index) {
                    $.get("setCarLotFinanceSettleStatus", {
                        carLotId: carLotId,
                        _time: new Date().getTime()
                    }, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1, time: 500}, function () {
                                location.reload();
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                        }
                        layer.close(index);
                    });
                }
            });
        })
    })
</script>
</html>
